﻿package me.zhengjie.common.exception

import org.springframework.util.StringUtils


/**
 * @author Kuki
 * @date 2024-11-10
 */
class EntityExistException(clazz: Class<*>, field: String, `val`: String) :
    RuntimeException(generateMessage(clazz.simpleName, field, `val`)) {
    companion object {
        private fun generateMessage(entity: String, field: String, `val`: String): String {
            return (StringUtils.capitalize(entity)
                    + " with " + field + " " + `val` + " existed")
        }
    }
}